{layout name="layouts/admin" /}
{js href="/static/admin/plugins/jQuery/jquery-1.9.1.min.js" /}
<div class="panel-heading">城市列表
</div>

<div class="panel-body">
    <div class="box-body">
        <div id="example2_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">
            <div class="row">
                <form action="/wechatgroup/citys" method="post" style="margin-bottom: 20px;">
                    <input type="text" class="form-control" style="width:250px;" value="{$keywords}" id="keywords" name="keywords" placeholder="请输入关键词"/>
                    <input type="submit" value="搜索" class="btn btn-primary"/>
                </form>
                <div class="col-sm-12">
                    <table class="table table-hover dataTable" >
                        <thead>
                        <tr>
                            <th>城市ID</th>
                            <th>城市名称</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {foreach $citydata as $item}
                        <tr>
                            <td>{$item.id}</td>
                            <td>{$item.city_name}</td>
                            <td>
                                <a href="javascript:void(0)" style="font-weight: bold;color:{$item.is_show==1?'green':'gray'}" onclick="cityoper(this,{$item.id})">{$item.is_show==1?'在手机端隐藏':'在手机端显示'}</a>

                            </td>
                        </tr>
                        {if $item.childs!=""}
                        {foreach $item.childs as $item2}
                        <tr>
                            <td>{$item2.id}</td>
                            <td style="color:#8b8d97">——{$item2.city_name}</td>
                            <td>
                                <a href="javascript:void(0)" style="font-weight: bold;color:{$item2.is_show==1?'green':'gray'}"  onclick="cityoper(this,{$item2.id})">{$item2.is_show==1?'在手机端隐藏':'在手机端显示'}</a>

                            </td>
                        </tr>
                        {/foreach}
                        {/if}
                        {/foreach}
                        </tbody>
                    </table>
                    <div class="col-sm-7" style="float: right">
                        {php}echo trim($citydata->render(),'"');{/php}
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-9 ">
                    {$citydata?"":"暂无数据"}
                </div>

            </div>
        </div>
    </div>

</div>

<script type="text/javascript">
    function cityoper(obj,dataid) {
        var datatype=$(obj).html();
        if(datatype=='在手机端显示')
        {
            //设置显示
            var itemtype=1;
            var datamsg="在手机端隐藏";
            var color="green";
        }else{
            //设置不显示
            var itemtype=0;
            var datamsg="在手机端显示";
            var color="gray";
        }
        $.ajax({
            type: "POST",
            url: "/wechatgroup/cityoper",
            data: "cityid=" + dataid+"&isshow="+itemtype,
            success: function (msg) {
                if (msg == 0) {
                    alert("设置成功");
                    $(obj).css('color',color);
                    $(obj).html(datamsg);
                }

            }
        });
    }
</script>